package com.qingxin.cms.entity;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.codehaus.jackson.annotate.JsonIgnore;
import org.hibernate.annotations.GenericGenerator;

/**
 * 文章表
 */
@Entity
@Table(name = "cms_article")
public class CmsArticle extends com.qingxin.sys.entity.BaseEntity implements
		java.io.Serializable {
	private static final long serialVersionUID = -6399314159262960355L;
	
	private String articleId;
	private CmsCategory cmsCategory;
	private String articleTitle;
	private String keyWord;
	private String articleDesc;
	private String thumb;//图片
	private String articleContent;
	private String createBy;
	private Date createTime;
	private String updateBy;
	private Date updateTime;
	private Set<CmsArticleAttachment> cmsArticleAttachments = new HashSet<>(0);
	private Integer carousel;
	private String parkid;
	// Constructors

	/** default constructor */
	public CmsArticle() {
	}
	
	public CmsArticle(String articleId, String articleTitle, Date createTime) {
		this.articleId = articleId;
		this.articleTitle = articleTitle;
		this.createTime = createTime;
	}

	
	public CmsArticle(String articleId, String articleTitle, String keyWord,
			String articleDesc, String thumb, String articleContent, Date createTime) {
		this.articleId = articleId;
		this.articleTitle = articleTitle;
		this.keyWord = keyWord;
		this.articleDesc = articleDesc;
		this.thumb = thumb;
		this.articleContent=articleContent;
		this.createTime = createTime;
	}


	

	public CmsArticle(String articleId, String articleTitle, String thumb,
			String articleContent, Date createTime) {
		super();
		this.articleId = articleId;
		this.articleTitle = articleTitle;
		this.thumb = thumb;
		this.articleContent = articleContent;
		this.createTime = createTime;
	}



	

	public CmsArticle(String articleId, String articleTitle, String keyWord,String articleDesc ,String thumb,String articleContent ,String createBy,
			Date createTime, String updateBy, Date updateTime,String categoryName) {
		super();
		this.articleId = articleId;
		this.articleTitle = articleTitle;
		this.keyWord = keyWord;
		this.articleDesc = articleDesc;
		this.thumb = thumb;
		this.articleContent = articleContent;
		this.createBy = createBy;
		this.createTime = createTime;
		this.updateBy = updateBy;
		this.updateTime = updateTime;
		this.cmsCategory = new CmsCategory();
		this.cmsCategory.setCategoryName(categoryName);
		
	}
	
	public CmsArticle(String articleId, String articleTitle, String keyWord,String createBy,
			Date createTime, String updateBy, Date updateTime,String categoryName) {
		super();
		this.articleId = articleId;
		this.articleTitle = articleTitle;
		this.keyWord = keyWord;
		this.createBy = createBy;
		this.createTime = createTime;
		this.updateBy = updateBy;
		this.updateTime = updateTime;
		this.cmsCategory = new CmsCategory();
		this.cmsCategory.setCategoryName(categoryName);
	}
	
	

	public CmsArticle(String articleId, String articleTitle, String thumb,Date createTime) {
		super();
		this.articleId = articleId;
		this.articleTitle = articleTitle;
		this.thumb = thumb;
		this.createTime = createTime;
	}


	/** full constructor */
	public CmsArticle(String articleId, CmsCategory cmsCategory,
			String articleTitle, String keyWord, String articleDesc,
			String thumb, String articleContent, String createBy,
			Date createTime, String updateBy, Date updateTime,
			Set<CmsArticleAttachment> cmsArticleAttachments, Integer carousel,
			String parkid) {
		super();
		this.articleId = articleId;
		this.cmsCategory = cmsCategory;
		this.articleTitle = articleTitle;
		this.keyWord = keyWord;
		this.articleDesc = articleDesc;
		this.thumb = thumb;
		this.articleContent = articleContent;
		this.createBy = createBy;
		this.createTime = createTime;
		this.updateBy = updateBy;
		this.updateTime = updateTime;
		this.cmsArticleAttachments = cmsArticleAttachments;
		this.carousel = carousel;
		this.parkid = parkid;
	}





	// Property accessors
	@GenericGenerator(name = "generator", strategy = "uuid.hex")
	@Id
	@GeneratedValue(generator = "generator")
	@Column(name = "article_id", unique = true, nullable = false, length = 32)
	public String getArticleId() {
		return this.articleId;
	}


	
	public void setArticleId(String articleId) {
		this.articleId = articleId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "category_id")
	public CmsCategory getCmsCategory() {
		return this.cmsCategory;
	}

	public void setCmsCategory(CmsCategory cmsCategory) {
		this.cmsCategory = cmsCategory;
	}

	@Column(name = "article_title", length = 200)
	public String getArticleTitle() {
		return this.articleTitle;
	}

	public void setArticleTitle(String articleTitle) {
		this.articleTitle = articleTitle;
	}

	@Column(name = "key_word", length = 100)
	public String getKeyWord() {
		return this.keyWord;
	}

	public void setKeyWord(String keyWord) {
		this.keyWord = keyWord;
	}

	@Column(name = "article_desc")
	public String getArticleDesc() {
		return this.articleDesc;
	}

	public void setArticleDesc(String articleDesc) {
		this.articleDesc = articleDesc;
	}

	@Column(name = "thumb", length = 200)
	public String getThumb() {
		return this.thumb;
	}

	public void setThumb(String thumb) {
		this.thumb = thumb;
	}

	@Column(name = "article_content")
	public String getArticleContent() {
		return this.articleContent;
	}

	public void setArticleContent(String articleContent) {
		this.articleContent = articleContent;
	}

	@Column(name = "create_by", length = 32)
	public String getCreateBy() {
		return this.createBy;
	}

	public void setCreateBy(String createBy) {
		this.createBy = createBy;
	}

	@Column(name = "create_time", length = 23)
	public Date getCreateTime() {
		return this.createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	@Column(name = "update_by", length = 32)
	public String getUpdateBy() {
		return this.updateBy;
	}

	public void setUpdateBy(String updateBy) {
		this.updateBy = updateBy;
	}

	@Column(name = "update_time", length = 23)
	public Date getUpdateTime() {
		return this.updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}
	
	@Column(name = "carousel")
	public Integer getCarousel() {
		return carousel;
	}

	public void setCarousel(Integer carousel) {
		this.carousel = carousel;
	}

	@Column(name = "parkid", length = 32)
	public String getParkid() {
		return parkid;
	}
	public void setParkid(String parkid) {
		this.parkid = parkid;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "cmsArticle")
	@JsonIgnore
	public Set<CmsArticleAttachment> getCmsArticleAttachments() {
		return this.cmsArticleAttachments;
	}
	public void setCmsArticleAttachments(
			Set<CmsArticleAttachment> cmsArticleAttachments) {
		this.cmsArticleAttachments = cmsArticleAttachments;
	}
	
}